*******************************************************************************
* appendix figure 15: only high income event studies

********************************************************************************

cd "$main_dir/data"

*** panel a: near far
use near_far_hi,clear
egen building_tag = tag(building_id)

egen ring_fe=group(building_id l250)
gen zero=0

gen treated=l250
gen treated_after=treated*(gap>=0)

reghdfe lrent tx_n3 tx_n2 zero tx_0 tx_1 tx_2 tx_3 /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 &  tx250_min_number>0 & tx256_min_number>0 ///
	[aweight=building_sample_weight] ,absorb(building_id building_id_year) vce(cl building_id)

coefplot, ///
	keep(tx* zero) ///			
	vert ///
	yline(0) xtitle(Years to treatment) ///
	rename(tx_n3 = "-3" tx_n2 = "-2" zero = "-1" tx_0="0" tx_1 = "1" tx_2 = "2" tx_3 = "3" tx_4="4")  ///
	ytitle("Log(rent)") graphregion(color(white)) bgcolor(white) ///
	yline(0) omitted

* dd coefficient in text
reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & tx250_min_number>0 & tx256_min_number>0 ///
	[aweight=building_sample_weight] ,absorb(ring_fe building_id_year) vce(cl building_id)

*** panel b: near near
use near_near_hi, clear
egen building_tag=tag(building_id)
tab msa building_built if building_tag == 1 & building_sample==1

* different cities have no control group than in main analysis.  drop here.
drop if inlist(msa, "philadelphia","seattle")>0

reghdfe lrent tx_n3 tx_n2 zero tx_0 tx_1 tx_2 tx_3 /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
coefplot, ///
	keep(tx* zero) ///			
	vert ///
	yline(0) xtitle(Years to treatment) ///
	rename(tx_n3 = "-3" tx_n2 = "-2" zero = "-1" tx_0="0" tx_1 = "1" tx_2 = "2" tx_3 = "3" tx_4="4")  ///
	ytitle("Log(rent)") graphregion(color(white)) bgcolor(white) ///
	yline(0) omitted

* dd coefficient in text
reghdfe lrent treated_after  /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
